<template>
	<view>
		<block v-if="now_status==0">
			<block v-if="!is_member">
				<view class="banner"></view>
				<view class="banner_modle_a">
					<view class="banner_modle_top">
						<image @tap="goset" class="banner_modle_top_img"
							:src="detail.user.head_image?detail.user.head_image:memberInfo.avatar"></image>
						<view class="banner_modle_top_title">{{memberInfo.nickname}}
							<button @tap="goset" class="shezhi" style="display:none;">
								<image class="shezhi_img" src="/static/pages/image/shezhi_icon.png"></image>
							</button>
						</view>
						<!-- <view bindtap="binding" class="banner_modle_top_btn">去入驻</view> -->
						<block v-if="memInfo.is_buyvip==0">
							<view @tap="toMenber" class="banner_modle_top_btn">成为会员</view>
						</block>
						<block v-if="memInfo.is_buyvip==1">
							<view v-if="memInfo.vip_level==1" @tap="toAsMenber" class="banner_modle_top_btn">普通会员</view>
							<view v-if="memInfo.vip_level==2" @tap="toAsMenber" class="banner_modle_top_btn">高级会员</view>
						</block>
					</view>
					<view class="banner_modle_down">
						<navigator class="banner_modle_down_modle" url="/pagesA/collection/index">
							<view class="banner_modle_down_modle_top">{{detail.stotal?detail.stotal:0}}</view>
							<view class="banner_modle_down_modle_down">收藏</view>
						</navigator>
						<!-- <view class="banner_modle_down_border"></view>
      <navigator class="banner_modle_down_modle" url="/pages/fensi/fensi?type=2">
        <view class="banner_modle_down_modle_top">{{detail.gtotal?detail.gtotal:0}}</view>
        <view class="banner_modle_down_modle_down">关注</view>
      </navigator> -->
						<view class="banner_modle_down_border"></view>
						<navigator class="banner_modle_down_modle" url="/pagesA/salelist/index">
							<view class="banner_modle_down_modle_top">{{detail.fbtotal?detail.fbtotal:0}}</view>
							<view class="banner_modle_down_modle_down">发布</view>
						</navigator>
						<view class="banner_modle_down_border"></view>
						<navigator class="banner_modle_down_modle" url="/pagesA/storeCollection/storeCollection">
							<view class="banner_modle_down_modle_top">{{detail.goods_favorites_count || 0}}</view>
							<view class="banner_modle_down_modle_down">商城收藏</view>
						</navigator>
					</view>
				</view>
			</block>
			<block v-else>
				<image class="banner1" :src="store_img?store_img:'/static/pages/image/store_bg.png'"></image>
				<button @tap="goset" class="shezhi1">
					<image class="shezhi_img1" src="/static/pages/image/shezhi_icon1.png"></image>
				</button>
				<view class="banner_message1">
					<image @tap="goset" class="banner_message_headImg1"
						:src="detail.user.head_image?detail.user.head_image:memberInfo.avatar"></image>
					<image class="banner_message_img1" src="/static/pages/image/yuanhu_icn.png"></image>
					<view class="banner_message_name1">{{memberInfo.nickname}}</view>
					<view class="banner_message_huiyuan1">认证店铺
						<image class="banner_message_huiyuan_img1" src="/static/pages/image/zuanshi_icn.png"></image>
					</view>
					<view class="banner_modle_down1">
						<view class="banner_modle_down_modle1">
							<navigator class="banner_modle_down_modle1" url="/pagesA/collection/index">
								<view class="banner_modle_down_modle_top1">{{detail.stotal?detail.stotal:0}}</view>
								<view class="banner_modle_down_modle_down1">收藏</view>
							</navigator>
						</view>
						<view class="banner_modle_down_border1"></view>
						<view class="banner_modle_down_modle1">
							<navigator class="banner_modle_down_modle1" url="/pages/fensi/fensi?type=2">
								<view class="banner_modle_down_modle_top1">{{detail.gtotal?detail.gtotal:0}}</view>
								<view class="banner_modle_down_modle_down1">关注</view>
							</navigator>
						</view>
						<view class="banner_modle_down_border1"></view>
						<view class="banner_modle_down_modle1">
							<navigator class="banner_modle_down_modle1" url="/pagesA/salelist/index">
								<view class="banner_modle_down_modle_top1">{{detail.fbtotal?detail.fbtotal:0}}</view>
								<view class="banner_modle_down_modle_down1">发布</view>
							</navigator>
						</view>
						<view class="banner_modle_down_border1"></view>
						<view class="banner_modle_down_modle1">
							<navigator class="banner_modle_down_modle1" url="/pages/fensi/fensi?type=1">
								<view class="banner_modle_down_modle_top1">{{detail.ftotal?detail.ftotal:0}}</view>
								<view class="banner_modle_down_modle_down1">粉丝</view>
							</navigator>
						</view>
					</view>
				</view>
			</block>
			<view class="modle" style="display:none;">
				<view @tap="tuiguang" class="banner_modle">
					<view class="modle_modle_border"></view>
					<image class="modle_modle_img" src="/static/pages/image/wdfb_btn.png"></image>
					<view class="modle_modle_name">推广中心</view>
				</view>
				<view @tap="mefabu" class="banner_modle">
					<view class="modle_modle_border"></view>
					<image class="modle_modle_img" src="/static/pages/image/fa.png"></image>
					<view class="modle_modle_name">我的发布</view>
				</view>
				<view @tap="weizhang" class="banner_modle">
					<view class="modle_modle_border"></view>
					<image class="modle_modle_img" src="/static/pages/image/weizhang_btn.png"></image>
					<view class="modle_modle_name">违章查询</view>
				</view>
				<view @tap="goPartOrder" class="banner_modle">
					<image class="modle_modle_img" src="/static/pages/image/qipei_btn.png"></image>
					<view class="modle_modle_name">汽配订购</view>
				</view>
			</view>
			<!-- <navigator class="choose_view" style="margin-top:20rpx;" url="/pages/publicity/index" wx:if="{{is_member}}">
  <view class="choose_view_modle">
    <image class="choose_view_modle_img" src="../image/tuiguangma_btn.png"></image>店铺码
    <image class="choose_view_modle_backImg" src="../image/jiantou_btn.png"></image>
    <text class="choose_view_modle_num"></text>
  </view>
</navigator>
<navigator class="choose_view" url="/pages/store/index">
  <view class="choose_view_modle">
    <image class="choose_view_modle_img" src="../image/yulan_icn.png"></image>店铺预览
    <image class="choose_view_modle_backImg" src="../image/jiantou_btn.png"></image>
    <text class="choose_view_modle_num"></text>
  </view>
</navigator>
<view class="choose_view">
  <view bindtap="retocollection" class="choose_view_modle">
    <image class="choose_view_modle_img" src="../image/wdsc_icn.png"></image>我的收藏
    <image class="choose_view_modle_backImg" src="../image/jiantou_btn.png"></image>
    <text class="choose_view_modle_num"></text>
  </view>
</view>
<navigator class="choose_view" url="/pages/fensi/fensi?type=2">
  <view class="choose_view_modle">
    <image class="choose_view_modle_img" src="../image/wodeguanzhu_icn.png"></image>我的关注
    <image class="choose_view_modle_backImg" src="../image/jiantou_btn.png"></image>
  </view>
</navigator>
<navigator class="choose_view" url="/pages/fensi/fensi?type=1">
  <view class="choose_view_modle">
    <image class="choose_view_modle_img" src="../image/gzwd_icn.png"></image>关注我的
    <image class="choose_view_modle_backImg" src="../image/jiantou_btn.png"></image>
  </view>
</navigator> -->
			<!-- <navigator class="choose_view" url="/pages/part/order/index">
    <view class="choose_view_modle">
        <image class="choose_view_modle_img" src="../image/partOrder.png"></image>汽配订单
        <image class="choose_view_modle_backImg" src="../image/jiantou_btn.png"></image>
    </view>
</navigator> -->
			<!-- <navigator class="choose_view" url="/pages/mine/joinUs/joinUs">
  <view class="choose_view_modle">
    <image class="choose_view_modle_img" src="../image/partOrder.png"></image>加入我们
    <image class="choose_view_modle_backImg" src="../image/jiantou_btn.png"></image>
  </view>
</navigator> -->
			<view class="my_order">
				<text class="order_title">我的订单</text>
				<view class="order_content">
					<view class="order_item" @tap="toMyOrders(1)">
						<image class="item_img" src="/static/pages/image/shipped.png"></image>
						<text class="item_txt">待发货</text>
					</view>
					<view class="order_item" @tap="toMyOrders(2)">
						<image class="item_img" src="/static/pages/image/wait_receiving.png"></image>
						<text class="item_txt">已发货</text>
					</view>
					<view class="order_item" @tap="toMyOrders(3)">
						<image class="item_img" src="/static/pages/image/completed.png"></image>
						<text class="item_txt">已完成</text>
					</view>
					<view class="order_item" @tap="toMyOrders(4)">
						<image class="item_img" src="/static/pages/image/all.png"></image>
						<text class="item_txt">全部</text>
					</view>
				</view>
			</view>
			<!-- <view class="nav"></view>
			<navigator class="choose_view" url="/pagesA/news/news">
				<view class="choose_view_modle">
					<image class="choose_view_modle_img" src="/static/pages/image/partOrder.png"></image>我的消息
					<image class="choose_view_modle_backImg" src="/static/pages/image/jiantou_btn.png"></image>
				</view>
			</navigator> -->
			<view class="nav" v-if="is_shop == 1"></view>
			<navigator v-if="is_shop == 1" class="choose_view" url="/pagesA/merchant/merchant">
				<view class="choose_view_modle">
					<image class="choose_view_modle_img" src="/static/pages/image/partOrder.png"></image>商家中心
					<image class="choose_view_modle_backImg" src="/static/pages/image/jiantou_btn.png"></image>
				</view>
			</navigator>
			<view class="nav"></view>
			<navigator class="choose_view" url="/pagesA/shoppingTrolley/shoppingTrolley">
				<view class="choose_view_modle">
					<image class="choose_view_modle_img" src="/static/pages/image/partOrder.png"></image>我的购物车
					<image class="choose_view_modle_backImg" src="/static/pages/image/jiantou_btn.png"></image>
				</view>
			</navigator>
			<view class="nav"></view>
			<navigator class="choose_view" url="/pagesA/salelist/index">
				<view class="choose_view_modle">
					<image class="choose_view_modle_img" src="/static/pages/image/partOrder.png"></image>我的卖车
					<image class="choose_view_modle_backImg" src="/static/pages/image/jiantou_btn.png"></image>
				</view>
			</navigator>
			<view class="nav"></view>
			<navigator class="choose_view" url="/pagesA/partList/partList?tid=2">
				<view class="choose_view_modle">
					<image class="choose_view_modle_img" src="/static/pages/image/partOrder.png"></image>我的配件库
					<image class="choose_view_modle_backImg" src="/static/pages/image/jiantou_btn.png"></image>
				</view>
			</navigator>
			<view class="nav"></view>
			<navigator class="choose_view" url="/pagesA/joinUs/joinUs?wh=3">
				<view class="choose_view_modle">
					<image class="choose_view_modle_img" src="/static/pages/image/partOrder.png"></image>我的招聘
					<image class="choose_view_modle_backImg" src="/static/pages/image/jiantou_btn.png"></image>
				</view>
			</navigator>
			<view class="nav"></view>
			<navigator class="choose_view" url="/pagesA/joinUs/joinUs?wh=4">
				<view class="choose_view_modle">
					<image class="choose_view_modle_img" src="/static/pages/image/partOrder.png"></image>我的租赁
					<image class="choose_view_modle_backImg" src="/static/pages/image/jiantou_btn.png"></image>
				</view>
			</navigator>
			<view class="nav" v-if="is_shop != 1 && isShop == 1"></view>
			<navigator v-if="is_shop != 1 && isShop == 1" class="choose_view" url="/pagesA/recruitment/recruitment">
				<view class="choose_view_modle">
					<image class="choose_view_modle_img" src="/static/pages/image/partOrder.png"></image>商家入驻
					<image class="choose_view_modle_backImg" src="/static/pages/image/jiantou_btn.png"></image>
				</view>
			</navigator>
			<view class="nav"></view>
			<!-- <navigator class="choose_view" url="../merchantList/merchantList">
				<view class="choose_view_modle">
					<image class="choose_view_modle_img" src="/static/pages/image/partOrder.png"></image>商家列表
					<image class="choose_view_modle_backImg" src="/static/pages/image/jiantou_btn.png"></image>
				</view>
			</navigator>
			<view class="nav"></view> -->
			<!-- <navigator class="choose_view" url="/pages/home/liuyan/liuyan">
  <view class="choose_view_modle">
    <image class="choose_view_modle_img" src="../image/chakanliuyan_icn.png"></image>查看留言
    <image class="choose_view_modle_backImg" src="../image/jiantou_btn.png"></image>
  </view>
</navigator>
<button class="choose_view" openType="contact">
  <view class="choose_view_modle">
    <image class="choose_view_modle_img" src="../image/kefu_icn.png"></image>客服帮助
    <image class="choose_view_modle_backImg" src="../image/jiantou_btn.png"></image>
  </view>
</button> -->
			<!--<import src="/pages/alert/index.wxml"></import>-->
			<block data-type="template" data-is="alert" data-attr="isShow:isShow">
				<view class="wx_dialog_container" :hidden="!isShow">
					<view class="wx-alert-mask"></view>
					<view class="wx-alert-dialog">
						<view class="wx-alert-dialog-title">尊敬的用户</view>
						<view class="wx-alert-dialog-content">尚未获取到您的用户信息，较多功能无法体验，请允许获取用户信息</view>
						<view class="wx-alert-dialog-footer">
							<button @tap="hideDialog" class="wx-alert-dialog-btn">拒绝</button>
							<button @getuserinfo="updateUserInfo" class="wx-alert-dialog-btn"
								open-type="getUserInfo">允许</button>
						</view>
					</view>
				</view>
			</block>
		</block>
		<block v-if="now_status==1">
			<view class="m_img_box">
				<image mode="aspectFill" :src="webUrl + 'addons/monai_market/static/wimgs/grzx_img.png'"></image>
			</view>
		</block>

		<new-order />
	</view>
</template>

<script>
	var app = getApp();
	import {
		genTestUserSig
	} from '@/utils/GenerateTestUserSig'
	export default {
		data() {
			return {
				isShow: !1,
				weizhang_open: 0,
				memInfo: '',
				now_status: 1,
				webUrl: '',
				is_shop: null,
				memberInfo: "",
				detail: "",
				is_member: "",
				store_img: "",
				qipei_open: "",
				isShop: 0
			};
		},
		components: {},
		props: {},
		onLoad: function(e) {
			// 会员信息
			var that = this;
			app.globalData.imgUrl();
			setTimeout(() => {
				that.setData({
					webUrl: wx.getStorageSync('webUrl')
				});
			}, 500);
			app.globalData.util.request({
				url: "entry/wxapp/Api",
				data: {
					m: "monai_market",
					r: "home.index.vipinfo",
					uid: app.globalData.getuid()
				},
				success: function(res) {
					console.log('会员返回', res.data);
					that.setData({
						memInfo: res.data.data
					});
				}
			});
		},
		onShow: async function() {
			var a = this;
			a.check_status();
			app.globalData.util.getUserInfo(async (e) => {
				e.memberInfo ? (a.setData({
					memberInfo: e.memberInfo
				}), wx.setStorageSync("uid", e.memberInfo.uid), a.firstin(e.memberInfo)) : a.setData({
					isShow: !0
				});
				if (e.memberInfo?.uid) {
					const userID = e.memberInfo.uid
					const userSig = genTestUserSig(userID).userSig
					const data = await this.$tim.login({
						userID,
						userSig
					})
				}
			});
			this.getIsShop()
			this.getIs_Shop()
		},
		onReachBottom: function() {},
		methods: {
			getIs_Shop() {
				app.globalData.util.request({
					url: "entry/wxapp/Api",
					data: {
						m: "monai_market",
						r: "home.index.is_shop"
					},
					success: res => {
						let {
							data
						} = res.data
						this.isShop = data
					},
					fail: res => {

					}
				});
			},
			// 我的订单
			toMyOrders(status) {
				wx.navigateTo({
					url: '/pagesA/myOrders/myOrders?status=' + status
				});
			},

			// 是否开店
			getIsShop() {
				app.globalData.util.request({
					url: "entry/wxapp/Api",
					data: {
						m: "monai_market",
						r: "shop.index.is_shop",
						uid: app.globalData.getuid()
					},
					success: res => {
						this.setData({
							is_shop: res.data.data
						});
					}
				});
			},

			check_status: function() {
				var that = this;
				app.globalData.util.request({
					url: "entry/wxapp/Api",
					data: {
						m: "monai_market",
						r: "home.index.examine"
					},
					success: function(res) {
						console.log('状态', res.data);
						that.setData({
							now_status: res.data.data
						});
					},
					fail: function(res) {}
				});
			},
			hideDialog: function() {
				this.setData({
					isShow: !this.isShow
				});
			},
			updateUserInfo: function(e) {
				var a = this;
				app.globalData.util.getUserInfo(function(e) {
					wx.setStorageSync("uid", e.memberInfo.uid), a.hideDialog(), a.firstin(e.memberInfo);
				}, e.detail);
			},
			//成为会员
			toMenber: function() {
				console.log('点击');
				// wx.navigateTo({
				//   url: '../member/member'
				// });
			},
			toAsMenber: function() {
				wx.navigateTo({
					url: '/pagesA/asMember/asMember'
				});
			},
			firstin: function(e) {
				var a = this;
				console.log(e), app.globalData.util.request({
					url: "entry/wxapp/Api",
					data: {
						m: "monai_market",
						r: "me.detail",
						uid: e.uid,
						head_image: e.avatar,
						nickname: e.nickname
					},
					success: function(e) {
						console.log(e), a.setData({
							detail: e.data.data,
							is_member: e.data.data.user.is_member,
							store_img: e.data.data.user.store_img,
							weizhang_open: e.data.data.weizhang_open,
							qipei_open: e.data.data.qipei_open
						});
						uni.setStorageSync('users',e.data.data.user)
					}
				});
			},
			goset: function() {
				wx.navigateTo({
					url: "/pages/mine/info/index"
				});
			},
			retopublicity: function() {
				wx.navigateTo({
					url: "/pages/publicity/index"
				});
			},
			binding: function() {
				wx.navigateTo({
					url: "/pagesA/enter/enter"
				});
			},
			retocollection: function() {
				wx.navigateTo({
					url: "/pagesA/collection/index"
				});
			},
			weizhang: function() {
				console.log(this.weizhang_open), 0 != this.weizhang_open ? wx.navigateTo({
					url: "/pages/weizhang/weizhang"
				}) : wx.showToast({
					title: "正在升级维护",
					icon: "loading",
					duration: 2e3
				});
			},
			tuiguang: function() {
				wx.navigateTo({
					url: "/pages/mine/sale/index"
				});
			},
			mefabu: function() {
				wx.navigateTo({
					url: "/pagesA/salelist/index"
				});
			},
			goPartOrder: function() {
				console.log(this.qipei_open), 0 != this.qipei_open ? wx.navigateTo({
					url: "/pagesA/part/apply/index"
				}) : wx.showToast({
					title: "正在升级开发",
					icon: "loading",
					duration: 2e3
				});
			}
		}
	};
</script>
<style>
	@import "./index.css";
</style>
